<template>
    <div class="pubphoto">
        <div class="top">
            <div class="left">
                <el-button type="primary" icon="ArrowLeft" circle size="small" @click="back" />
                <span class="zuo">发布相册</span>
            </div>
            <div class="right">
                <el-button @click="back">取消</el-button>
                <el-button type="primary" @click="fabu">发布</el-button>
            </div>
        </div>
        <div class="content">
            <el-form ref="formref" :model="Form" class="demo-ruleForm" enctype="multipart/form-data"
                action="http://mrwsmt.natappfree.cc/school/photos/savePhotos">
                <el-form-item label="发布者姓名：" prop="name">
                    <el-input type="input" placeholder="写下精彩瞬间" v-model="Form.name" />
                </el-form-item>
                <el-form-item label="发布内容：" prop="detail">
                    <el-input type="textarea" placeholder="写下精彩瞬间" rows="10" v-model="Form.detail" />
                </el-form-item>
                <el-form-item label="发布图片：">
                    <el-upload class="upload-img" action="" list-type="picture">
                        <el-button size="small" type="danger">点击上传</el-button>
                    </el-upload>
                </el-form-item>
                <el-form-item label="发布：">
                    <el-button type="primary" @click="fabu(formref)">发布</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>

<script setup lang="ts">
import server from '@/api/index'
import { ref, onMounted } from 'vue'
// import { ElMessage } from 'element-plus'
// import { Plus } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router';
var inputele = ref('')
var Form = ref({ name: '', detail: '', img: '' })
var formref = ref()
var changes = (e: any) => {
    // console.log(inputele.value);
    Form.value.img = e.target.files[0].name
    //    console.log("http://mrwsmt.natappfree.cc/"+e.target.files[0].name);
}
var fabu = async (formEl: any) => {
    // console.log(formref.value);
    var res = await server.home.savePhotos(Form.value)
    // console.log(res);
}
var router = useRouter()
var back = () => {
    router.go(-1)
}
</script>

<style scoped>
.top {
    width: 100%;
    height: 70px;
    border-bottom: 1px solid #ccc;
    box-shadow: 0px 0px 3px;
    line-height: 70px;
    position: sticky;
    background: #fff;
    top: 0;
    z-index: 2;
}

.left {
    float: left;
    margin-left: 20px;
}

.right {
    float: right;
    margin-right: 20px;
}

.zuo {
    margin-left: 10px;
    color: blue;
}

.content {
    width: 1200px;
    /* background: #aaa; */
    height: 500px;
    margin: 80px auto 0 auto;
    padding: 10px;
}

.avatar-uploader .avatar {
    width: 178px;
    height: 178px;
    display: block;
}

.avatar-uploader .el-upload {
    border: 1px dashed var(--el-border-color);
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: var(--el-transition-duration-fast);
}

.avatar-uploader .el-upload:hover {
    border-color: var(--el-color-primary);
}

.el-icon.avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    text-align: center;
}
</style>